'''
Created on Apr 22, 2012

@author: samindaw
'''

from net.pycbr.CBR import  KScriptBase, KBScriptEngine, read_script

sb=KScriptBase()

sb.add_script(read_script("../resources/samples/scripts/Accident"))
sb.add_script(read_script("../resources/samples/scripts/beach.txt"))
sb.add_script(read_script("../resources/samples/scripts/concert.txt"))
sb.add_script(read_script("../resources/samples/scripts/Eating_Lunch"))
sb.add_script(read_script("../resources/samples/scripts/going_to_work"))
sb.add_script(read_script("../resources/samples/scripts/grumpy_morning.txt"))
sb.add_script(read_script("../resources/samples/scripts/gym"))
sb.add_script(read_script("../resources/samples/scripts/hard_boil_eggs"))
sb.add_script(read_script("../resources/samples/scripts/house_fire"))
sb.add_script(read_script("../resources/samples/scripts/In_office.txt"))
sb.add_script(read_script("../resources/samples/scripts/library.txt"))
sb.add_script(read_script("../resources/samples/scripts/making_coffee.txt"))
sb.add_script(read_script("../resources/samples/scripts/park.txt"))
sb.add_script(read_script("../resources/samples/scripts/Playing_soccer"))
sb.add_script(read_script("../resources/samples/scripts/script_essay_writing.txt"))
sb.add_script(read_script("../resources/samples/scripts/script_tea_making.txt"))
sb.add_script(read_script("../resources/samples/scripts/sick.txt"))
sb.add_script(read_script("../resources/samples/scripts/studying_newspaper"))
sb.add_script(read_script("../resources/samples/scripts/taking_pictures.txt"))
sb.add_script(read_script("../resources/samples/scripts/watching_tv"))

engine=KBScriptEngine(sb)

print "Making fruit juice"
print "=================="
sentences1=[]
sentences1.append({"subject":"person","action":"add","utility":"fruits,water,blender"})
sentences1.append({"subject":"blender","action":"blend","utility":"fruits"})
sentences1.append({"subject":"person","action":"drink","utility":"juice"})

results=engine.search_script(sentences1)
for result in results: print result[0].name+"\t: "+str(result[2])

print
print "Score a goal"
print "============"
sentences2=[]
sentences2.append({"subject":"player","action":"aim","utility":"ball,goal"})
sentences2.append({"subject":"player","action":"hit","utility":"ball"})
sentences2.append({"subject":"player","action":"duck","utility":"others"})
sentences2.append({"subject":"player","action":"score","utility":"goal"})
results=engine.search_script(sentences2)
for result in results: print result[0].name+"\t: "+str(result[2])


